package yaxis.test.tools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Timestamp {
	public static String Readable(){
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date curDate = new Date(System.currentTimeMillis());

		return(formatter.format(curDate));
	}
	
	public static long Digital(){
		return(System.currentTimeMillis());
	}
	
	public static long Readable2Digital(String timeReadable){
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		Date d;
		
		try {
			d = formatter.parse(timeReadable);
			return(d.getTime()); 
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return -1;
		}
	}
	
	public static String Digital2Readable(long timeDigital){
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return(formatter.format(new Date(timeDigital * 1000L)));
	}
}
